﻿#include<iostream>
using namespace::std;

// 牛客

//JZ64 求1+2+3+...+n
class Solution
{
    // 内部类
    class Sum
    {
    public:
        Sum()
        {
            _ret += _i;
            ++_i;
        }
    };
public:
    int Sum_Solution(int n)
    {
        Sum arr[n];
        return _ret;
    }
private:
    static int _i;
    static int _ret;
};
// 静态成员变量类外初始化
int Solution::_i = 1;
int Solution::_ret = 0;


// HJ73 计算日期到天数转换
int main()
{
	int year = 0, month = 0, day = 0;
	cin >> year >> month >> day;
	int monthDay[13] = { -1,31,28,31,30,31,30,31,31,30,31,30,31 };
	//闰年
	if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
	{
		monthDay[2] = 29;
	}
	int sum = 0;
	for (int i = 1; i < month; i++)
	{
		sum += monthDay[i];
	}
	sum += day;
	cout << sum << endl;
	return 0;
}


//KY111 日期差值
int main()
{
	int day1, day2, mon1, mon2, year1, year2;
	int monthDay[13] = { -1,31,28,31,30,31,30,31,31,30,31,30,31 };

	scanf("%4d%2d%2d", &year1, &mon1, &day1);
	scanf("%4d%2d%2d", &year2, &mon2, &day2);

	int sum1 = 0, sum2 = 0;
	for (int i = 0; i < year1; i++)
	{
		if ((year1 % 4 == 0 && year1 % 100 != 0) || (year1 % 400 == 0))
		{
			sum1 += 366;
		}
		else
		{
			sum1 += 365;
		}
	}
	for (int i = 0; i < year2; i++)
	{
		if ((year2 % 4 == 0 && year2 % 100 != 0) || (year2 % 400 == 0))
		{
			sum2 += 366;
		}
		else
		{
			sum2 += 365;
		}
	}

	for (int i = 1; i < mon1; i++)
	{
		sum1 += monthDay[i];
		if ((year1 % 4 == 0 && year1 % 100 != 0) || (year1 % 400 == 0))
		{
			sum1++;
		}
	}
	sum1 += day1;

	for (int i = 1; i < mon2; i++)
	{
		sum2 += monthDay[i];
		if ((year2 % 4 == 0 && year2 % 100 != 0) || (year2 % 400 == 0))
		{
			sum2++;
		}
	}
	sum2 += day2;

	int day = 0;
	if (sum1 > sum2)
	{
		day = sum1 - sum2;
	}
	else
	{
		day = sum2 - sum1;
	}

	cout << day + 1 << endl;
	return 0;
}


//KY258 日期累加
int main()
{
	int n = 0;
	cin >> n;

	for (int j = 0; j < n; j++)
	{
		int year = 0, month = 0, day = 0;
		int sum_day = 0;
		int monthDay[13] = { -1,31,28,31,30,31,30,31,31,30,31,30,31 };
		cin >> year >> month >> day >> sum_day;
		if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
		{
			monthDay[2] = 29;
		}

		day += sum_day;

		while (day > monthDay[month])
		{
			day -= monthDay[month];
			month++;
			if (month > 12)
			{
				month -= 12;
				year++;
				monthDay[2] = 28;
				if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
				{
					monthDay[2] = 29;
				}
			}
		}
		printf("%d-%02d-%02d\n", year, month, day);
	}

	return 0;
}


//KY222 打印日期
int main() 
{
    int year = 0, day = 0;
    while (cin >> year >> day) 
    { 
		int month = 1;
        int monthDay[13] = { -1,31,28,31,30,31,30,31,31,30,31,30,31 };
		if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
		{
			monthDay[2] = 29;
		}
        while (day > monthDay[month])
		{
			day -= monthDay[month];
			month++;
			if (month > 12)
			{
				month -= 12;
				year++;
				monthDay[2] = 28;
				if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
				{
					monthDay[2] = 29;
				}
			}
		}
		printf("%d-%02d-%02d\n", year, month, day);
    }

	return 0;
}


